import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * Author: Daniel Michalski
 * Date: 05.04.13
 */

public class DirList {

    public static final String DIR_PATH = "src";

    public static void main(String[] args) {
        try (DirectoryStream<Path> dirstrm =
                     Files.newDirectoryStream(Paths.get(DIR_PATH)))
        {
            for (Path entry : dirstrm) {
                BasicFileAttributes attribs =
                        Files.readAttributes(entry, BasicFileAttributes.class);
                if (attribs.isDirectory())
                    System.out.print("<DIR> ");
                else
                    System.out.print(" ");

                System.out.println(entry.getName(1));
            }
        } catch (InvalidPathException e) {
            System.out.println("Błąd ściezki: " + e);
        } catch (NotDirectoryException e) {
            System.out.println(DIR_PATH + " nie jest katalogiem.");
        } catch (IOException e) {
            System.out.println("Błąd wejscia-wyjścia: " + e);
        }
    }
}